<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<style type="text/css">
		*{
			margin: 0;
			padding: 0;
		}
		body{
			background: #ccc;
			height: 1000px;
		}
		.main{
			width: 500px;
			height: 300px;
			background: #eee;
			margin: 100px auto;
		}
		.box{
			width: 200px;
			height: 200px;
			background: orange;
		}
	</style>
</head>
<body>

<div class="main">
	<div class="box"></div>
</div>
<script type="text/javascript">
	let box = document.querySelector('.box')

	box.onclick = function(e){
		//clientX clientY点击的位置距离当前body可视区域的距离
		// console.log(e.clientX,e.clientY)
		// pageX  pageY 点击的距离对于整个页面来说，包含滚动条折叠部分
		// console.log(e.pageX,e.pageY)
		//screenX  screenY点击的位置距离电脑屏幕的距离
		// console.log(e.screenX,e.screenY)
		// offsetX offsetY对于触发元素的左边和上边距离
		console.log(e.offsetX,e.offsetY)
	}
</script>
</body>
</html>